import request from '@/services/api'
import {UserInfo} from '@/type'

export async function login (username: string, password: string): Promise<string> {
  let ret = await request.post('/login', {
    username, password
  })
  return ret?.data.Token ?? ''
}

export async function register (username: string, password: string, nickname: string, phone: string, address: string) {
  let ret = await request.post('/register', {
    username, password, nickname, phone, address
  })
  return ret?.data?.Token??''
}

export async function updateUserInfo (userInfo: UserInfo) {
  await request.post('/person/updateUserInfo', {
    ...userInfo,
    nickname: userInfo.nickName
  })
}

export async function requestUserInfo () {
  const ret = await request.get('/person/getUserInfo')
  return ret?.data?.userInfo??{}
}


